﻿@model List<HQPad.Models.ItemBase>

<h2>Items &amp; Abilities</h2>

@if (Model != null && Model.Count > 0)
{
    <ul class="armour-list">
        @foreach(var item in Model) {
            <li class="type-item @Html.Raw((item.Equipped) ? "equipped" :  "")" style="@Html.Raw("background-image: url(" + item.Icon.RelativePath + ");")">
                <div class="left">
                <span class="name">@Html.Raw(item.Name)</span>

                @if (item is HQPad.Models.Item)
                {
                    
                    switch (((HQPad.Models.Item)item).Use)
                    {
                        case HQPad.Helpers.ItemUseType.AlwaysOn: {
                            <br /><span class="use">@Html.Raw("Always on")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.OnceEver: {
                            <br /><span class="use">@Html.Raw("One use ever")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.Unlimited: {
                            <br /><span class="use">@Html.Raw("Unlimited charges")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.Charged: {
                            <br /><span class="use">@Html.Raw(((HQPad.Models.Item)item).Charges.ToString() + " charges")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.Recharges: {
                            <br /><span class="use">@Html.Raw(((HQPad.Models.Item)item).Charges.ToString() + " charges / " + ((HQPad.Models.Item)item).Frequency)</span>
                            break;
                        }
                        default : {
                            break;
                        }
                    }
                    
                }
                else if (item is HQPad.Models.Ability)
                {

                    switch (((HQPad.Models.Ability)item).Use)
                    {
                        case HQPad.Helpers.ItemUseType.AlwaysOn: {
                            <br /><span class="use">@Html.Raw("Always on")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.OnceEver: {
                            <br /><span class="use">@Html.Raw("One use ever")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.Unlimited: {
                            <br /><span class="use">@Html.Raw("Unlimited charges")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.Charged: {
                            <br /><span class="use">@Html.Raw(((HQPad.Models.Ability)item).Charges.ToString() + " charges")</span>
                            break;
                        }
                        case HQPad.Helpers.ItemUseType.Recharges: {
                            <br /><span class="use">@Html.Raw(((HQPad.Models.Ability)item).Charges.ToString() + " charges / " + ((HQPad.Models.Ability)item).Frequency)</span>
                            break;
                        }
                        default : {
                            break;
                        }
                    }
                    
                }               
                @if (!string.IsNullOrEmpty(item.Description))
                {
                    <br /><span class="description">@Html.Raw(item.Description)</span>
                }
                
                </div>
                <div class="middle">
                    @if (item.Type == HQPad.Helpers.ItemType.Item)
                    {
                        <p>@Html.ActionLink("edit", "EditItem", "Character", new { id = item.Id }, new { @class = "edit-record modal-window-custom-long button", @target = "_blank", title = "Edit the details for this item" })</p>
                    }
                    else if (item.Type == HQPad.Helpers.ItemType.Ability)
                    {
                        <p>@Html.ActionLink("edit", "EditAbility", "Character", new { id = item.Id }, new { @class = "edit-record modal-window-custom button", @target = "_blank", title = "Edit the details for this ability" })</p>
                    }
                    else if (item.Type == HQPad.Helpers.ItemType.Potion)
                    {
                        <p>@Html.ActionLink("edit", "EditPotion", "Character", new { id = item.Id }, new { @class = "edit-record modal-window-custom button", @target = "_blank", title = "Edit the details for this potion" })</p>
                    }
                    <p>@Html.ActionLink("remove", "RemoveItem", "Character", new { id = item.Id }, new { @class = "remove-item button", title = "Discard this item" })</p>
                    <p>@Html.ActionLink(item.Equipped ? "unequip" : "equip", "EquipItem", "Character", new { id = item.Id }, new { @class = "equip-item button " + ((item.Equipped) ? "unequip" : "equip"), data_equipped = item.Equipped.ToString().ToLower(), title = "Equip or un-equip this item" })</p>

                    @if (item.Type == HQPad.Helpers.ItemType.Scroll)
                    {
                        if (((HQPad.Models.Scroll)item).Written)
                        {
                            <p>@Html.ActionLink("clear scroll", "ClearScroll", "Character", new { id = item.Id }, new { @class = "edit-record modal-window button", @target = "_blank", title = "Clear the spell or invocation for this scroll." })</p>
                        }
                        else
                        {
                            <p>@Html.ActionLink("write scroll", "WriteScroll", "Character", new { id = item.Id }, new { @class = "edit-record modal-window button", @target = "_blank", title = "Write a spell or invocation to this scroll." })</p>
                        }
                    }

                </div>
                <div class="right">
                    @Html.Partial("~/Views/Shared/QualitySummaryList.cshtml", item.Qualities)
                    <p class="qualitites-button">@Html.ActionLink("qualities", "EditQualities", new { id = item.Id }, new { @class = "modal-window-custom button", @target = "_blank" })</p>
                </div>
            </li>
        }
    </ul>
}
else
{
    <p>You have no items, abilites, scrolls or potions.</p>
}